#define READ_SUCCESS 0
#define READ_FAILURE 1
#define INPUT_ERROR  2

typedef struct {
  IDL_KW_RESULT_FIRST_FIELD; /* Must be first entry in structure */

  /* These must be in alpabetical order */

  IDL_VPTR columns;
  int columns_there;

  int csv;
  int csv_there;

  int help;
  int help_there;

  IDL_VPTR rows;
  int rows_there;

  /* Status of the call */
  IDL_VPTR status;
  int status_there;

  
  int verbose;
  int verbose_there;
  
} KW_RESULT;

static IDL_KW_PAR kw_pars[] = {

  IDL_KW_FAST_SCAN, 

  /* These must be in alphabetical order */

  /* 
     IDL_KW_VIN: can be just an input, like var=3
     IDL_KW_OUT: can be output variable, var=var
     IDL_KW_ZERO: If not there, variable is set to 0

     If the VIN is set, then the _there variables will be
     0 when an undefined name variable is sent: no good for
     returning variables!
  */

  /* Column and row numbers to read */
  {"COLUMNS", IDL_TYP_UNDEF, 1, IDL_KW_VIN, 
   (int *) IDL_KW_OFFSETOF(columns_there), (char *) IDL_KW_OFFSETOF(columns)},

  {"CSV", IDL_TYP_INT, 1, 0, 
   IDL_KW_OFFSETOF(csv_there), IDL_KW_OFFSETOF(csv) },

  {"HELP", IDL_TYP_INT, 1, 0, 
   IDL_KW_OFFSETOF(help_there), IDL_KW_OFFSETOF(help) },


  {"ROWS", IDL_TYP_UNDEF, 1, IDL_KW_VIN, 
   (int *) IDL_KW_OFFSETOF(rows_there), (char *) IDL_KW_OFFSETOF(rows)},


  {"STATUS", IDL_TYP_UNDEF, 1, IDL_KW_OUT | IDL_KW_ZERO, 
   IDL_KW_OFFSETOF(status_there), IDL_KW_OFFSETOF(status) },

  
  {"VERBOSE", IDL_TYP_INT, 1, 0, 
   IDL_KW_OFFSETOF(verbose_there), IDL_KW_OFFSETOF(verbose) },
  

  { NULL }
};

/* Function prototypes */

/* Put in main because uses kw */

int ar_scanval(FILE *fptr, char *format, char *buffer);
void ar_printval(int code, char *membuf);
int ar_skiplines(FILE *fptr, int nskip);

char **ar_scan_formats(int csv);
void ar_free_scan_formats(char **scan_formats);

void ar_set_status(int statusVal);

int ar_nparams(int argc);
void ar_syntax(int help);
